export default {
  checkPlugins: pluginName => {
    var np = navigator.plugins
    if (window.ActiveXObject) {
      // IE
      // ActiveXObject的对象名
      var activexObjectName = pluginName + "." + pluginName
      try {
        var axobj = eval("new ActiveXObject(activexObjectName);")
        // 将对象转化为布尔类型
        return axobj ? true : false
      } catch (e) {
        return false
      }
    } else if (np && np.length) {
      // 非IE
      for (var i = 0; i < np.length; i++) {
        if (np[i].name.toLowerCase().indexOf(pluginName.toLowerCase()) > -1)
          return true
      }
      return false
    } else {
      // 其他则返回false
      return false
    }
  },
  putParamsInUrl: params =>
    `?` +
    Object.keys(params)
      .map(k =>
        [encodeURIComponent(k), encodeURIComponent(params[k])].join("=")
      )
      .join("&"),

  filterBlankValue: object => {
    for (let key in object) {
      if (!object[key]) {
        delete object[key]
      }
    }
    return object
  },

  isBlankArray: array => {
    let flag = false
    array.forEach(t => {
      if (!t) {
        flag = true
      }
    })
    return flag
  }
}
